class Solution
{
public:
    bool isAlienSorted(vector<string> &words, string order)
    {
        unordered_map<char, char> charMap;
        for (int i = 0; i < 26; ++i)
        {
            charMap[order[i]] = 'a' + i;
        }
        auto convert = [&](string &s)
        {
            for (char &c : s)
            {
                c = charMap[c];
            }
        };
        for (auto &word : words)
        {
            convert(word);
        }
        return is_sorted(words.begin(), words.end());
    }
};